﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo;

namespace Ice.Demo.Clent
{
    public class Client
    {
        public static void Main(string[] args) 
        {
            int status = 0;
            Ice.Communicator ic = null;
            try
            {
                ic = Ice.Util.initialize(ref args);
                Ice.ObjectPrx obj = ic.stringToProxy("SimplePrinter:default -p 10000");
                PrinterPrx printer = PrinterPrxHelper.checkedCast(obj);
                if (printer == null)
                {
                    throw new ApplicationException("Invalid proxy");
                }
                printer.printString("Hello World!");
            }
            catch (Exception e) 
            {
                Console.Error.WriteLine(e);
                status = 1;
            }
            if (ic != null) 
            {
                //Clean up
                try
                {
                    ic.destroy();
                }
                catch (Exception e) 
                {
                    Console.Error.WriteLine(e);
                    status = 1;
                }
            }
            Environment.Exit(status);
        }
    }
}
